package com.ruoyi.civil.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.civil.domain.CivilEnginneeringTreatment;
import com.ruoyi.civil.service.ICivilEnginneeringTreatmentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 病害处治Controller
 * 
 * @author ruoyi
 * @date 2022-05-11
 */
@RestController
@RequestMapping("/civil/treatment")
public class CivilEnginneeringTreatmentController extends BaseController
{
    @Autowired
    private ICivilEnginneeringTreatmentService civilEnginneeringTreatmentService;

    /**
     * 查询病害处治列表
     */
    @PreAuthorize("@ss.hasPermi('civil:treatment:list')")
    @GetMapping("/list")
    public TableDataInfo list(CivilEnginneeringTreatment civilEnginneeringTreatment)
    {
        startPage();
        List<CivilEnginneeringTreatment> list = civilEnginneeringTreatmentService.selectCivilEnginneeringTreatmentList(civilEnginneeringTreatment);
        return getDataTable(list);
    }

    /**
     * 导出病害处治列表
     */
    @PreAuthorize("@ss.hasPermi('civil:treatment:export')")
    @Log(title = "病害处治", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CivilEnginneeringTreatment civilEnginneeringTreatment)
    {
        List<CivilEnginneeringTreatment> list = civilEnginneeringTreatmentService.selectCivilEnginneeringTreatmentList(civilEnginneeringTreatment);
        ExcelUtil<CivilEnginneeringTreatment> util = new ExcelUtil<CivilEnginneeringTreatment>(CivilEnginneeringTreatment.class);
        util.exportExcel(response, list, "病害处治数据");
    }

    /**
     * 获取病害处治详细信息
     */
    @PreAuthorize("@ss.hasPermi('civil:treatment:query')")
    @GetMapping(value = "/{tTreatmentId}")
    public AjaxResult getInfo(@PathVariable("tTreatmentId") Long tTreatmentId)
    {
        return AjaxResult.success(civilEnginneeringTreatmentService.selectCivilEnginneeringTreatmentByTTreatmentId(tTreatmentId));
    }

    /**
     * 新增病害处治
     */
    @PreAuthorize("@ss.hasPermi('civil:treatment:add')")
    @Log(title = "病害处治", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CivilEnginneeringTreatment civilEnginneeringTreatment)
    {
        return toAjax(civilEnginneeringTreatmentService.insertCivilEnginneeringTreatment(civilEnginneeringTreatment));
    }

    /**
     * 修改病害处治
     */
    @PreAuthorize("@ss.hasPermi('civil:treatment:edit')")
    @Log(title = "病害处治", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CivilEnginneeringTreatment civilEnginneeringTreatment)
    {
        return toAjax(civilEnginneeringTreatmentService.updateCivilEnginneeringTreatment(civilEnginneeringTreatment));
    }

    /**
     * 删除病害处治
     */
    @PreAuthorize("@ss.hasPermi('civil:treatment:remove')")
    @Log(title = "病害处治", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tTreatmentIds}")
    public AjaxResult remove(@PathVariable Long[] tTreatmentIds)
    {
        return toAjax(civilEnginneeringTreatmentService.deleteCivilEnginneeringTreatmentByTTreatmentIds(tTreatmentIds));
    }
}
